<?php

session_start();

$output_line = '';

$output_line =
'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' . "\n" .
'<!--[if IE]>' . "\n" .
'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">' . "\n" .
'<![endif]-->' . "\n" .
'<html xmlns="http://www.w3.org/1999/xhtml" ';

echo $output_line;

language_attributes();

$output_line = '>' . "\n" .
'<head profile="http://gmpg.org/xfn/11">' . "\n" .
'   <meta http-equiv="Content-Type" content="' . get_bloginfo('html_type') . '; charset=' . get_bloginfo('charset') . '" />' . "\n" . '   <title>';

echo $output_line;
$output_line = '';

if ( is_search() )
{
	$ser = $_GET['s'];
	_e('Search', 'german_newspaper');
	$output_line = ' &quot;' . wp_specialchars($ser, 1) . '&quot;';
}

$output_line .= wp_title('');

if ( ! is_home() )
{
	$output_line .= ' | ';
}

$output_line .= get_bloginfo('name') . '</title>' . "\n" .
'   <meta name="generator" content="WordPress ' . get_bloginfo('version') . '" />
   <meta name="keywords" content="" />
   <meta name="description" content="" />
   <meta name="author" content="" />
   <link rel="shortcut icon" type="image/x-icon" href="' . get_bloginfo('template_directory') . '/favicon.ico" />
   <link rel="stylesheet" href="' . get_bloginfo('stylesheet_url') . '" type="text/css" media="screen, projection" />' . "\n";
   
echo $output_line;

$screen_width	= get_option( "gn_screen_width" );

if ( $screen_width == 'on' )
{
	$head	= 3;
	$output_line =
'   <link rel="stylesheet" href="' . get_bloginfo('template_directory') . '/css/style-800.css" type="text/css" media="screen, projection" />' . "\n";
}
else
{
	$head	= 4;
	$output_line =
'   <link rel="stylesheet" href="' . get_bloginfo('template_directory') . '/css/style-1024.css" type="text/css" media="screen, projection" />' . "\n";
}

echo $output_line;

$output_line =
'   <link rel="stylesheet" href="' . get_bloginfo('template_directory') . '/css/tab-panel.css" type="text/css" media="screen, projection" />
<!--[if IE]>
   <link rel="shortcut icon" type="image/vnd.microsoft.icon" href="' . get_bloginfo('template_directory') . '/favicon.ico" />' . "\n";

echo $output_line;

if ( $screen_width == 'on' )
{
	$output_line =
'   <link rel="stylesheet" type="text/css" media="screen, projection" href="' . get_bloginfo('stylesheet_directory') . '/css/ie-style-800.css" />' . "\n";
}
else
{
	$output_line =
'   <link rel="stylesheet" type="text/css" media="screen, projection" href="' . get_bloginfo('stylesheet_directory') . '/css/ie-style-1024.css" />' . "\n";
}

echo $output_line;

$output_line =
'<![endif]-->
   <link rel="alternate" type="application/rss+xml" title="' . get_bloginfo('name') . ' RSS Feed" href="' . get_bloginfo('rss2_url') . '" />
   <link rel="pingback" href="' . get_bloginfo('pingback_url') . '" />' . "\n";

echo $output_line;
$output_line = '';

wp_head();

echo '</head>' . "\n";


$body_color					= get_option( "gn_body_color" );
$body_background		= get_option( "gn_body_background" );
$wrapper_background	= get_option( "gn_wrapper_background" );

$output_line =
'<body style="color:' . $body_color . ' background:' . $body_background . '">' . "\n\n" .
'  <div id="wrapper" style="background:' . $wrapper_background . '">' . "\n\n" .
'    <div id="header">' . "\n" .
'      <h2><a href="' . get_option('home') . '/" title="' . get_bloginfo('name') . '">' . get_bloginfo('name') . '</a></h2>' . "\n" .
'      <div class="description">' . get_bloginfo('description') . '</div>' . "\n" .
'      <br /><br />' . "\n" .
'      <div class="date">';

echo $output_line;
$output_line = '';

_e(date('l - j. F Y'), 'german_newspaper');

$output_line .= '</div>' . "\n" .
'    </div>' . "\n\n" .
'    <div id="page_bar_container" style="background:' . $wrapper_background . '">' . "\n" .
'      <div class="page_bar">' . "\n" .
'        <ul class=page_tabs>' . "\n" .
'          <li><a href="' . get_option('home') . '/" title="' . get_bloginfo('name') . '">Home</a></li>' . "\n";

echo $output_line;
$output_line = '';

wp_list_pages( array('title_li' => '', 'depth' => '-1', 'exclude' => get_option( "gn_page_exclude" )) );

$output_line .=
'        </ul>' . "\n" .
'      </div>' . "\n" .
'    </div>' . "\n\n";

echo $output_line;


if ( is_home() )
{
	$left_img		= get_option( 'gn_left_img' );
	$right_img	= get_option( 'gn_right_img' );
	$home				= get_option( 'home' );

	$output_line = '';
	$output_line =
'    <div id="newslist" style="background:' . $wrapper_background . '">' . "\n" .
'      <div class="description">' . __('Headlines', 'german_newspaper') . '</div>' . "\n" .
'      <table id="news_table" cellspacing="0">' . "\n" .
'        <tr>' . "\n" .
/*'       <div class="news">' . "\n" .*/
'          <td width="170px">' . "\n" .
'            <div class="left_image">' . "\n" .
'				       <img src="' . $left_img . '" alt="News-Image">' . "\n" .
'            </div>' . "\n\n" .
'				   </td>' . "\n";

	echo $output_line;
	$output_line = '';

	$counter_head = 0;

	if ( have_posts() )
	{
		while ( have_posts() )
		{
			the_post();

			if ( $counter_head < $head)
			{
				$output_line .=
'          <td id="news_table_col">' . "\n" .
'            <div class="post" id="post-' . get_the_ID() . '">' . "\n" . get_the_category_list(', ') . "\n" .
'              <br><br>' . "\n" .
'              <h2>' . the_title('', '', false) . '</h2>' . "\n" .
'              <p><a href="' . apply_filters('the_permalink', get_permalink()) . '" rel="bookmark" title="Permalink: ' . the_title('', '', false) . '"><em>' . __('More on page ', 'german_newspaper') . $post->ID . '</em></a></p>' . "\n" .
'            </div>' . "\n" .
'          </td>' . "\n\n";

				echo $output_line;
				$output_line = '';

				$counter_head++;
			}
		}
		
		if ( $counter_head < $head )
		{
		  //  build empty table columns
		  for ( $i = $counter_head; $i < $head; $i++ )
		  {
				$output_line .=
'          <td id="news_table_col">' . "\n" .
'					   <div class="post" id="post-">' . "\n" .
'					     <br><br>' . "\n" .
'					   </div>' . "\n" .
'					 </td>' . "\n\n";

				$counter_head++;
			}
			echo $output_line;
			$output_line = '';
		}
	}
	else
	{
	  //  build empty table columns
	  for ( $i = $counter_head; $i < $head; $i++ )
	  {
			$output_line .=
'          <td id="news_table_col">' . "\n" .
'					   <div class="post" id="post-">' . "\n" .
'					     <br><br>' . "\n" .
'					   </div>' . "\n" .
'					 </td>' . "\n\n";

			$counter_head++;
		}
		echo $output_line;
		$output_line = '';
	}

	$output_line .=
'          <td width="170px">' . "\n" .
'					   <div class="right_image">' . "\n" .
'					     <img src="' . $right_img . '" alt="News-Image">' .
'					   </div>' . "\n" .
'          </td>' . "\n" .
'        </tr>' . "\n" .
'      </table>' . "\n" .
/*'				</div>' . "\n" .*/
'    </div>' . "\n\n";

	echo $output_line;
	$output_line = '';

	echo  '    <div class="clear"></div>' . "\n\n";
}

//  start content container
echo '    <div id="content_container">' . "\n";

//  build left sidebar
get_sidebar();


?>